# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libyaml' 'libyaml-devel')
pkgver=0.2.2
pkgrel=1
pkgdesc="YAML 1.1 library"
arch=('i686' 'x86_64')
url="https://pyyaml.org/wiki/LibYAML"
license=('MIT')
source=(https://pyyaml.org/download/libyaml/yaml-${pkgver}.tar.gz
        'yaml-0.1.7-fix-undefined.patch'
        'yaml-0.1.7-msys2.patch')
sha256sums=('4a9100ab61047fd9bd395bcef3ce5403365cafd55c1e0d0299cde14958e47be9'
            'fba2535decf076c0a6b260db01e163e665c5fc92fe7edaa90246d31810082387'
            '30781f6c15848c84f6b285854389dca08ec06f161fe4440b7dac055b0bbbb0d9')

prepare() {
  cd "${srcdir}/yaml-${pkgver}"

  patch -p1 -i ${srcdir}/yaml-0.1.7-fix-undefined.patch
  patch -p1 -i ${srcdir}/yaml-0.1.7-msys2.patch

  autoreconf -fiv
}

build() {
  cd "${srcdir}/yaml-${pkgver}"
  ./configure \
     --build=${CHOST} \
     --prefix=/usr

  make
  make DESTDIR="$srcdir/dest" install
  install -m644 -D LICENSE ${srcdir}/dest/usr/share/licenses/${pkgname}/LICENSE
}

package_libyaml() {
  groups=('libraries')

  install -dm755 ${pkgdir}/usr/bin
  install -m755 -t ${pkgdir}/usr/bin ${srcdir}/dest/usr/bin/*.dll
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libyaml-devel() {
  groups=('development')
  depends=("libyaml=${pkgver}")

  install -dm755 ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
